@use '@material/theme/theme-color' as mdc-theme-color;
@use '@material/snackbar' as mdc-snackbar;
@use 'sass:color';
@use 'sass:map';
@use '../mdc-helpers/mdc-helpers';
@use '../../material/core/theming/theming';


@mixin color($config-or-theme) {
  $config: theming.get-color-config($config-or-theme);

  $orig-fill-color: mdc-snackbar.$fill-color;
  $orig-label-ink-color: mdc-snackbar.$label-ink-color;
  $orig-dismiss-ink-color: mdc-snackbar.$dismiss-ink-color;

  @include mdc-helpers.mat-using-mdc-theme($config) {
    mdc-snackbar.$fill-color: color.mix(
      mdc-theme-color.prop-value(on-surface),
      mdc-theme-color.prop-value(surface),
      80%
    );
    mdc-snackbar.$label-ink-color: rgba(
      mdc-theme-color.prop-value(surface),
      mdc-theme-color.text-emphasis(high)
    );
    mdc-snackbar.$dismiss-ink-color: rgba(
      mdc-theme-color.prop-value(surface),
      mdc-theme-color.text-emphasis(high)
    );

    @include mdc-snackbar.core-styles($query: mdc-helpers.$mat-theme-styles-query);
  }

  mdc-snackbar.$fill-color: $orig-fill-color;
  mdc-snackbar.$label-ink-color: $orig-label-ink-color;
  mdc-snackbar.$dismiss-ink-color: $orig-dismiss-ink-color;

  // The extra level of nesting here is to increase the specificity.
  .mat-mdc-simple-snack-bar .mat-mdc-snack-bar-actions .mdc-snackbar__action {
    $is-dark-theme: map.get($config, is-dark);
    $accent: map.get($config, accent);
    color: if($is-dark-theme, inherit, theming.get-color-from-palette($accent, text));

    .mat-ripple-element {
      background-color: currentColor;
      opacity: 0.1;
    }
  }
}

@mixin typography($config-or-theme) {
  $config: theming.get-typography-config($config-or-theme);
  @include mdc-helpers.mat-using-mdc-typography($config) {
    @include mdc-snackbar.core-styles($query: mdc-helpers.$mat-typography-styles-query);
  }
}

@mixin density($config-or-theme) {}

@mixin theme($theme-or-color-config) {
  $theme: theming.private-legacy-get-theme($theme-or-color-config);
  @include theming.private-check-duplicate-theme-styles($theme, 'mat-mdc-snack-bar') {
    $color: theming.get-color-config($theme);
    $density: theming.get-density-config($theme);
    $typography: theming.get-typography-config($theme);

    @if $color != null {
      @include color($color);
    }
    @if $density != null {
      @include density($density);
    }
    @if $typography != null {
      @include typography($typography);
    }
  }
}

